<script setup>
import MyForm from "@/components/MyForm.vue";
import {onMounted, shallowReactive, shallowRef} from "vue";
import {RULE} from "@/const";
import MyNav from "@/components/MyNav.vue";
import router from "@/router";
import {updateApi} from "@/api/RoleApi";
import {listApi} from "@/api/RoomApi";
import {getResponseData} from "@/util";

// 所在房间下拉菜单选项
let optionItems = [];
// 获取角色记录
let role = JSON.parse(sessionStorage.getItem('role'));

// 表单项
let items = shallowRef([
  {'label': '角色名称', 'prop': 'title'},
  {'label': '角色描述', 'prop': 'info', 'type': 'textarea'},
]);
// 表单默认值
let data = shallowReactive({
  'id': role['id'],
  'title': role['title'],
  'info': role['info'] ? role['info'] : '记录暂无描述',
});
// 表单规则
let rules = {
  'info': RULE.COMMON_INFO,
  'title': RULE.COMM_TITLE,
};


/* ==================== 加载函数 ==================== */
</script>

<template>

  <my-nav :items="[
  {'icon': 'User', 'label': '角色管理'},
  {'icon': 'User', 'label': '角色列表', 'url': '/ums/Role'},
  {'icon': 'User', 'label': '修改角色'},
]"/>

  <el-divider/>
  <my-form type="update"
           :items="items"
           :data="data"
           :rules="rules"
           :api="updateApi"
           :fn="() => router.push('/ums/Role')"
           :span="1"/>

</template>

<style scoped lang="scss">

</style>